package com.hadwinling.lot.controller;

import com.hadwinling.lot.service.LotdbService;
import org.apache.iotdb.rpc.IoTDBConnectionException;
import org.apache.iotdb.rpc.StatementExecutionException;
import org.apache.iotdb.session.SessionDataSet;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * @description:
 * @author: hadwinling
 * @time: 2021/2/5 下午3:53
 */
@Controller
public class LotDBController {

    @Resource
    private LotdbService lotdbService;


    @GetMapping("/set/{storage}")
    @ResponseBody
    public String showStorageGroup(@PathVariable(name = "storage") String storage ) {
        System.out.println("输入的是："+storage);
        try {
            lotdbService.setStorageGroup(storage);
        } catch (StatementExecutionException e) {
            e.printStackTrace();
        } catch (IoTDBConnectionException e) {
            e.printStackTrace();
        }
        return "over";
    }






    @GetMapping("/search")
    @ResponseBody
    public SessionDataSet searchAll() throws StatementExecutionException, IoTDBConnectionException {
        SessionDataSet sessionDataSet = lotdbService.searchAll();
        System.out.println(sessionDataSet);
        return sessionDataSet;
    }

}
